//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.utils.basehelper.distance;

import org.apache.commons.lang3.StringUtils;

public class DistanceUtil {
    public DistanceUtil() {
    }

    private static double rad(double d) {
        return d * 3.141592653589793D / 180.0D;
    }

    public static Double lngLatDist(String lon1, String lat1, String lon2, String lat2) {
        if (!StringUtils.isBlank(lon1) && !StringUtils.isBlank(lat1) && !StringUtils.isBlank(lon2) && !StringUtils.isBlank(lat2)) {
            double radLat1 = rad(new Double(lat1));
            double radLat2 = rad(new Double(lat2));
            double radLot1 = rad(new Double(lon1));
            double radLot2 = rad(new Double(lon2));
            double a = radLat1 - radLat2;
            double b = radLot1 - radLot2;
            double s = 2.0D * Math.asin(Math.sqrt(Math.abs(Math.pow(Math.sin(a / 2.0D), 2.0D) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2.0D), 2.0D))));
            s *= 6378.137D;
            s = (double)Math.round(s);
            return s;
        } else {
            return null;
        }
    }
}
